package com.xinhe.web.reposity;

import com.xinhe.web.entity.AssetCount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;
import java.util.List;

public interface AssetCountRepository  extends JpaRepository<AssetCount, Long> {

    @Query(value = "select remainder from tb_asset_count where f_user_id=?1 and type='RMB' ", nativeQuery = true)
    BigDecimal queryRmb(Long userId);

    @Query(value = "select remainder from tb_asset_count where type=?1 AND f_user_id=?2", nativeQuery = true)
    AssetCount findByTypeAndUserId(String type, Long userId);

    @Query(value = "select * from tb_asset_count where removed = 0 and type = ?1 and f_user_id = ?2", nativeQuery = true)
    AssetCount findOneByTypeAndUserId(String type, Long userId);
    @Query(value = "select * from tb_asset_count where removed = 0 and f_user_id =?1 ", nativeQuery = true)
    List<AssetCount> findByUserId(Long userId);
}
